﻿using DevExpress.XtraReports.UI;
using System.IO;

namespace ConfExpert.Forms.Rapor.Aksesuar
{
    public class AksesuarSiparisFoyu
    {
        xrAksesuarSiparisFoy report = new xrAksesuarSiparisFoy();
        public AksesuarSiparisFoyu(string POIds, bool ShowPreview = true)
        {
            //TODOAKS: yurt içi - yurt dışı buradan belli olmalı
            xrAksesuarSiparisFoy rTR = new xrAksesuarSiparisFoy();
            xrAksesuarSiparisFoyEN rEN = new xrAksesuarSiparisFoyEN();

            //if (NewPOIds.Select("YurtIci = 1").Length > 0)
            //{
            //    string ids = NewPOIds.Select("YurtIci = 1").CopyToDataTable().GetValuesofSpecifiedColumn("AksPOId", ",");
            rTR.iGetByPOId(POIds);
            rTR.CreateDocument();
            //}

            //if (NewPOIds.Select("YurtIci = 0").Length > 0)
            //{
            //    string ids = NewPOIds.Select("YurtIci = 0").CopyToDataTable().GetValuesofSpecifiedColumn("AksPOId", ",");
            rEN.iGetByPOId(POIds);
            rEN.CreateDocument();
            //}

            report.Pages.Clear();
            report.Pages.AddRange(rTR.Pages);
            report.Pages.AddRange(rEN.Pages);

            if (ShowPreview)
                report.ShowPreview();
        }

        public byte[] GetReportAsBytes()
        {
            MemoryStream ms = new MemoryStream();
            report.ExportToPdf(ms);
            return ms.ToArray();
        }
    }
}
